﻿using ShareCode.Dto;
using ShareCode.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClientDao
{
    public abstract class BaseTreeDal<T> : BaseContainTitleDal<T> where T : BaseTreeEntity, new()
    {

        public async Task<ResultDto<T>> GetTreeRoot(long Id)
        {
            var imgstream = await PostAsync<T>($"GetTreeRoot/{Id}");

            return imgstream;
        }

        public async Task<ResultDto<List<long>>> GetTreeParentIds(long Id)
        {
            var imgstream = await PostAsync<List<long>>($"GetTreeParentIds/{Id}");

            return imgstream;
        }

        public async Task<ResultDto<bool>> TreeInsertSon(T entity)
        {
            var imgstream = await PostAsync<T, bool>($"TreeInsertSon", entity);

            return imgstream;
        }

        public async Task<ResultDto<bool>> TreeInsertBefore(T entity, long Id)
        {
            var imgstream = await PostAsync<T, bool>($"TreeInsertBefore/{Id}", entity);

            return imgstream;
        }

        public async Task<ResultDto<bool>> TreeInsertAfter(T entity, long Id)
        {
            var imgstream = await PostAsync<T, bool>($"TreeInsertAfter/{Id}", entity);

            return imgstream;
        }



    }
}
